#!/bin/bash
root_dir="/usr/local/edata"
role=$1
mode=$(cat mode)
echo "$(date +"%Y-%m-%d %H:%M:%S") INFO starting $role in $mode mode"
function start_jobmanager(){
    jobmanager.sh start
}

function start_taskmanager(){
    taskmanager.sh start
}

if [ $role == "jobmanager" ];then
	start_master
fi

if [ $role == "taskmanager" ];then
	start_worker
fi

if [ $role == "all" ];then
	if [ $mode == "ha" ];then
		echo "$(date +"%Y-%m-%d %H:%M:%S") WARNING parameter all is only supported in sa mode"
		exit 1
	fi
	start_jobmanager
	start_taskmanager
fi
